const EMPTY_STRING = "";
const PORTABLE_EXECUTABLE_DIR = process.env.PORTABLE_EXECUTABLE_DIR;
const IS_PORTABLE =
  PORTABLE_EXECUTABLE_DIR && PORTABLE_EXECUTABLE_DIR !== EMPTY_STRING;

const APP_THEME = {
  AUTO: "auto",
  LIGHT: "light",
  DARK: "dark",
};

const APP_RUN_MODE = {
  STANDARD: 1,
  TRAY: 2,
  HIDE_TRAY: 3,
};

const ADD_TASK_TYPE = {
  URI: "uri",
  TORRENT: "torrent",
};

const TASK_STATUS = {
  ACTIVE: "active",
  WAITING: "waiting",
  PAUSED: "paused",
  ERROR: "error",
  COMPLETE: "complete",
  REMOVED: "removed",
  SEEDING: "seeding",
};

const LOG_LEVELS = ["error", "warn", "info", "verbose", "debug", "silly"];

const MAX_NUM_OF_DIRECTORIES = 5;

const ENGINE_RPC_HOST = "127.0.0.1";
const ENGINE_RPC_PORT = 6800;
const ENGINE_MAX_CONCURRENT_DOWNLOADS = 10;
const ENGINE_MAX_CONNECTION_PER_SERVER = 64;

const UNKNOWN_PEERID =
  "%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00";
const UNKNOWN_PEERID_NAME = "unknown";
const GRAPHIC = "░▒▓█";

const ONE_SECOND = 1000;
const ONE_MINUTE = ONE_SECOND * 60;
const ONE_HOUR = ONE_MINUTE * 60;
const ONE_DAY = ONE_HOUR * 24;

// 12 Hours
const AUTO_SYNC_TRACKER_INTERVAL = ONE_HOUR * 12;

// One Week
const AUTO_CHECK_UPDATE_INTERVAL = ONE_DAY * 7;

const MAX_BT_TRACKER_LENGTH = 6144;

/**
 * @see https://github.com/ngosang/trackerslist
 */
const NGOSANG_TRACKERS_BEST_URL =
  "https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_best.txt";
const NGOSANG_TRACKERS_BEST_IP_URL =
  "https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_best_ip.txt";
const NGOSANG_TRACKERS_ALL_URL =
  "https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_all.txt";
const NGOSANG_TRACKERS_ALL_IP_URL =
  "https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_all_ip.txt";

const NGOSANG_TRACKERS_BEST_URL_CDN =
  "https://cdn.jsdelivr.net/gh/ngosang/trackerslist/trackers_best.txt";
const NGOSANG_TRACKERS_BEST_IP_URL_CDN =
  "https://cdn.jsdelivr.net/gh/ngosang/trackerslist/trackers_best_ip.txt";
const NGOSANG_TRACKERS_ALL_URL_CDN =
  "https://cdn.jsdelivr.net/gh/ngosang/trackerslist/trackers_all.txt";
const NGOSANG_TRACKERS_ALL_IP_URL_CDN =
  "https://cdn.jsdelivr.net/gh/ngosang/trackerslist/trackers_all_ip.txt";

/**
 * @see https://github.com/XIU2/TrackersListCollection
 */
const XIU2_TRACKERS_BEST_URL =
  "https://raw.githubusercontent.com/XIU2/TrackersListCollection/master/best.txt";
const XIU2_TRACKERS_ALL_URL =
  "https://raw.githubusercontent.com/XIU2/TrackersListCollection/master/all.txt";
const XIU2_TRACKERS_HTTP_URL =
  "https://raw.githubusercontent.com/XIU2/TrackersListCollection/master/http.txt";

const XIU2_TRACKERS_BEST_URL_CDN =
  "https://cdn.jsdelivr.net/gh/XIU2/TrackersListCollection/best.txt";
const XIU2_TRACKERS_ALL_URL_CDN =
  "https://cdn.jsdelivr.net/gh/XIU2/TrackersListCollection/all.txt";
const XIU2_TRACKERS_HTTP_URL_CDN =
  "https://cdn.jsdelivr.net/gh/XIU2/TrackersListCollection/http.txt";

// For bt-exclude-tracker
const XIU2_TRACKERS_BLACK_URL =
  "https://cdn.jsdelivr.net/gh/XIU2/TrackersListCollection/blacklist.txt";

const TRACKER_SOURCE_OPTIONS = [
  {
    label: "ngosang/trackerslist",
    options: [
      {
        value: NGOSANG_TRACKERS_BEST_URL,
        label: "trackers_best.txt",
        cdn: false,
      },
      {
        value: NGOSANG_TRACKERS_BEST_IP_URL,
        label: "trackers_best_ip.txt",
        cdn: false,
      },
      {
        value: NGOSANG_TRACKERS_ALL_URL,
        label: "trackers_all.txt",
        cdn: false,
      },
      {
        value: NGOSANG_TRACKERS_ALL_IP_URL,
        label: "trackers_all_ip.txt",
        cdn: false,
      },
      {
        value: NGOSANG_TRACKERS_BEST_URL_CDN,
        label: "trackers_best.txt",
        cdn: true,
      },
      {
        value: NGOSANG_TRACKERS_BEST_IP_URL_CDN,
        label: "trackers_best_ip.txt",
        cdn: true,
      },
      {
        value: NGOSANG_TRACKERS_ALL_URL_CDN,
        label: "trackers_all.txt",
        cdn: true,
      },
      {
        value: NGOSANG_TRACKERS_ALL_IP_URL_CDN,
        label: "trackers_all_ip.txt",
        cdn: true,
      },
    ],
  },
  {
    label: "XIU2/TrackersListCollection",
    options: [
      {
        value: XIU2_TRACKERS_BEST_URL,
        label: "best.txt",
        cdn: false,
      },
      {
        value: XIU2_TRACKERS_ALL_URL,
        label: "all.txt",
        cdn: false,
      },
      {
        value: XIU2_TRACKERS_HTTP_URL,
        label: "http.txt",
        cdn: false,
      },
      {
        value: XIU2_TRACKERS_BEST_URL_CDN,
        label: "best.txt",
        cdn: true,
      },
      {
        value: XIU2_TRACKERS_ALL_URL_CDN,
        label: "all.txt",
        cdn: true,
      },
      {
        value: XIU2_TRACKERS_HTTP_URL_CDN,
        label: "http.txt",
        cdn: true,
      },
    ],
  },
];

const PROXY_SCOPES = {
  DOWNLOAD: "download",
  UPDATE_APP: "update-app",
  UPDATE_TRACKERS: "update-trackers",
};

const PROXY_SCOPE_OPTIONS = [
  PROXY_SCOPES.DOWNLOAD,
  PROXY_SCOPES.UPDATE_APP,
  PROXY_SCOPES.UPDATE_TRACKERS,
];

const NONE_SELECTED_FILES = "none";
const SELECTED_ALL_FILES = "all";

const IP_VERSION = {
  V4: 4,
  V6: 6,
};

const LOGIN_SETTING_OPTIONS = {
  // For Windows
  args: ["--opened-at-login=1"],
};

const TRAY_CANVAS_CONFIG = {
  WIDTH: 66,
  HEIGHT: 16,
  ICON_WIDTH: 16,
  ICON_HEIGHT: 16,
  TEXT_WIDTH: 46,
  TEXT_FONT_SIZE: 8,
};

const COMMON_RESOURCE_TAGS = ["http://", "https://", "ftp://", "magnet:"];
const THUNDER_RESOURCE_TAGS = ["thunder://"];

const RESOURCE_TAGS = [...COMMON_RESOURCE_TAGS, ...THUNDER_RESOURCE_TAGS];

const SUPPORT_RTL_LOCALES = [
  /* 'العربية', Arabic */
  "ar",
  /* 'فارسی', Persian */
  "fa",
  /* 'עברית', Hebrew */
  "he",
  /* 'Kurdî / كوردی', Kurdish */
  "ku",
  /* 'پنجابی', Western Punjabi */
  "pa",
  /* 'پښتو', Pashto, */
  "ps",
  /* 'سنڌي', Sindhi */
  "sd",
  /* 'اردو', Urdu */
  "ur",
  /* 'ייִדיש', Yiddish */
  "yi",
];

const IMAGE_SUFFIXES = [
  ".ai",
  ".bmp",
  ".eps",
  ".fig",
  ".gif",
  ".heic",
  ".icn",
  ".ico",
  ".jpeg",
  ".jpg",
  ".png",
  ".psd",
  ".raw",
  ".sketch",
  ".svg",
  ".tif",
  ".webp",
  ".xd",
];

const AUDIO_SUFFIXES = [
  ".aac",
  ".ape",
  ".flac",
  ".flav",
  ".m4a",
  ".mp3",
  ".ogg",
  ".wav",
  ".wma",
];

const VIDEO_SUFFIXES = [
  ".avi",
  ".m4v",
  ".mkv",
  ".mov",
  ".mp4",
  ".mpg",
  ".rmvb",
  ".vob",
  ".wmv",
];

const SUB_SUFFIXES = [".ass", ".idx", ".smi", ".srt", ".ssa", ".sst", ".sub"];

const DOCUMENT_SUFFIXES = [
  ".azw3",
  ".csv",
  ".doc",
  ".docx",
  ".epub",
  ".key",
  ".mobi",
  ".numbers",
  ".pages",
  ".pdf",
  ".ppt",
  ".pptx",
  ".txt",
  ".xsl",
  ".xslx",
];

module.exports = {
  EMPTY_STRING,
  PORTABLE_EXECUTABLE_DIR,
  IS_PORTABLE,
  APP_THEME,
  APP_RUN_MODE,
  ADD_TASK_TYPE,
  TASK_STATUS,
  LOG_LEVELS,
  MAX_NUM_OF_DIRECTORIES,
  ENGINE_RPC_HOST,
  ENGINE_RPC_PORT,
  ENGINE_MAX_CONCURRENT_DOWNLOADS,
  ENGINE_MAX_CONNECTION_PER_SERVER,
  UNKNOWN_PEERID,
  UNKNOWN_PEERID_NAME,
  GRAPHIC,
  ONE_SECOND,
  ONE_MINUTE,
  APP_THEME,
  ONE_HOUR,
  ONE_DAY,
  AUTO_SYNC_TRACKER_INTERVAL,
  AUTO_CHECK_UPDATE_INTERVAL,
  MAX_BT_TRACKER_LENGTH,

  NGOSANG_TRACKERS_BEST_URL,
  NGOSANG_TRACKERS_BEST_IP_URL,
  NGOSANG_TRACKERS_ALL_URL,
  NGOSANG_TRACKERS_ALL_IP_URL,

  NGOSANG_TRACKERS_BEST_URL_CDN,
  NGOSANG_TRACKERS_BEST_IP_URL_CDN,


  NGOSANG_TRACKERS_ALL_URL_CDN,
  NGOSANG_TRACKERS_ALL_IP_URL_CDN,


  XIU2_TRACKERS_BEST_URL,
  XIU2_TRACKERS_ALL_URL,
  XIU2_TRACKERS_HTTP_URL,
  XIU2_TRACKERS_BEST_URL_CDN,
  XIU2_TRACKERS_ALL_URL_CDN,
  XIU2_TRACKERS_HTTP_URL_CDN,
  XIU2_TRACKERS_BLACK_URL,
  TRACKER_SOURCE_OPTIONS,
  PROXY_SCOPES,
  PROXY_SCOPE_OPTIONS,
  NONE_SELECTED_FILES,
  SELECTED_ALL_FILES,
  IP_VERSION,
  LOGIN_SETTING_OPTIONS,
  TRAY_CANVAS_CONFIG,
  COMMON_RESOURCE_TAGS,
  THUNDER_RESOURCE_TAGS,
  RESOURCE_TAGS,
  SUPPORT_RTL_LOCALES,
  IMAGE_SUFFIXES,
  AUDIO_SUFFIXES,
  VIDEO_SUFFIXES,
  SUB_SUFFIXES,
  DOCUMENT_SUFFIXES,
  
};
